package com.ruoyi.salesInvoice.invoiceStatusMachine;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 发票状态机工厂类
 * @Author Mr.Yi.Zhang
 * @Version 1.0
 */
@Component
public class InvoiceServiceFactory {

    private final Map<String, InvoiceService> content = new HashMap<>();

    @Autowired
    public InvoiceServiceFactory(List<InvoiceService> services) {
        for (InvoiceService service : services) {
            content.put(service.get(), service);
        }
    }

    public InvoiceService query(String flag) {
        return content.get(flag);
    }
}
